package com.gelsanalyzer.ui.swing;

import java.awt.event.*;

import javax.swing.*;

import com.gelsanalyzer.business.control.*;
import com.gelsanalyzer.ui.swing.command.*;

public class CourseMgmtMenuBar extends JMenuBar {
    // Store the commands that we will need to manipulate. For each of these 
    // commands, we will have accessors so that the implementing controller can
    // get references to them.
    private SaveCommand fileMenuSave;
    private ExitCommand fileMenuExit;
    private AddCourseCommand editMenuAddCourse;

    public CourseMgmtMenuBar(Handler parentFrame) {
        // Start by creating the File option...
        JMenu fileMenu = new JMenu("File", true);
        fileMenu.setMnemonic(KeyEvent.VK_F);
        // Next create the Edit option...
        JMenu editMenu = new JMenu("Edit", true);
        editMenu.setMnemonic(KeyEvent.VK_E);

        // Initialize the Command objects for the MenuBar here:
        fileMenuSave = new SaveCommand("Save");
        fileMenuExit = new ExitCommand("Exit", fileMenuSave);

        editMenuAddCourse = new AddCourseCommand("Add Course", parentFrame);
        editMenuAddCourse.setEnabled(false);

        // Add the listeners to the MenuItems
        fileMenuExit.addActionListener(parentFrame);
        fileMenuSave.addActionListener(parentFrame);
        
        editMenuAddCourse.addActionListener(parentFrame);
        
        // Temporarily disable items...
        fileMenuSave.setEnabled(false);
        
        // Add the actual Command objects to the menu
        fileMenu.add(fileMenuSave);
        fileMenu.add(fileMenuExit);

        editMenu.add(editMenuAddCourse);

        //Add the actual Menu to the MenuBar
        this.add(fileMenu);
        this.add(editMenu);
    }

    public SaveCommand getFileMenuSaveCommand() {
        return fileMenuSave;
    }

    public JMenuItem getFileSaveMenuItem() {
        return fileMenuSave;
    }

    public ExitCommand getFileMenuExitCommand() {
        return fileMenuExit;
    }

    public JMenuItem getFileExitMenuItem() {
        return fileMenuExit;
    }

    public JMenuItem getEditAddCourseMenuItem() {
        return editMenuAddCourse;
    }

    public AddCourseCommand getEditMenuAddCourseCommand() {
        return editMenuAddCourse;
    }
}
